package com.example.lhsama.controller;

import com.example.lhsama.domain.Category;
import com.example.lhsama.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @Date: 2021年10月29日 12:45
 * @Author: LHSAMA
 */
@Controller
@RequestMapping("/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @RequestMapping("/list")
    public ModelAndView list(){
        ModelAndView mv = new ModelAndView();
        List<Category> categorys = categoryService.list();
        mv.addObject("categorys",categorys);
        mv.setViewName("category_list");

        return mv;

    }

}
